<template>
  <div id="looktime">  
   
    <el-row>
       <el-col :span="12">  
        <div style="height:38px;line-height:38px;width:150px;"> 
              <i class="el-icon-back" @click="goBack"></i>   
              返回           
         </div> 
         </el-col>
        <el-col :span="12" style="text-align: right;">         
            <el-button type="primary" class="custom_color_button" style="margin-bottom:10px;" @click="add_but">添加显示时间</el-button>         
        </el-col>
  </el-row>

   <!-- 渲染数据list -->
   <look-time-list :datalist="datalist" @up_list_fun="list_fun"> </look-time-list>

      
   <!-- <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div> -->
   

      <!-- 显示时间 -->
    <el-dialog title="显示时间" :visible.sync="add_mtk"  width="400px">
        <div style="width:100%;"> 


        <el-form ref="form"   label-width="70px" style="width:100%;">
    
               <el-form-item label="" label-width="0px">
                    <el-col :span="11">
                        <el-date-picker type="date" :clearable='false'  placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="from.time1" style="width:160px;"></el-date-picker>
                    </el-col>
                    <el-col class="line" :span="2" style="text-align: center;">-</el-col>
                    <el-col :span="11">
                         <el-date-picker type="date" :clearable='false'  placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="from.time2" style="width:160px;"></el-date-picker>
                    </el-col>
              </el-form-item> 
                 <el-form-item label-width="0px" >
                <el-select  v-model="from.select1_num" placeholder="请选择果种等级" style="width:160px;">
                    <el-option  v-for="(item,index) in select1_data" :key="index" :label="item.title" :value="item.maid"></el-option>
                </el-select>
             </el-form-item>  
                         
            </el-form>

            <div style="text-align: center;width:50%;margin:auto;margin-top:20px;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="add_but_qr">确认</el-button>
            </div>

        </div> 
    </el-dialog>
    

      
  </div>
</template>

<script>
import LookTimeList from '@/view/Exchangeorder/LookTimeList'
export default {
  name: 'looktime',
  data () {
    return {
        datalist:[],
        page:1,
        count:0,
        add_mtk:false,
        from:{
            time1:'',
            time2:'',
             select1_num:'',
        },
        select1_data:[],
    }
  },
 components:{
    LookTimeList
  },
  created(){
     this.list_fun()
      this.list_zy()
  },
  mounted (){
    
  },
  methods: {
    list_zy(){
      this.post("/manor/manorOption", {
       }).then(res => { 
           this.select1_data = res.result   
                           
       })
    },
      list_fun(){
          this.post("/split_log/listOfShowBtnDate", {
              page:this.page,
              type:2, //1拆解 2拆分
	        }).then(res => {
            // this.count = res.result.count
            this.datalist = res.result
            //console.log(res)
         })
      },
      add_but(){
           this.from.time1 = ''
           this.from.time2 = ''
            this.from.select1_num  = ''
           this.add_mtk = true
      },
      add_but_qr(){
          console.log(this.from.time1)
          console.log(this.from.time2)
           this.post("/split_log/addBtnDate", {
                   start:this.from.time1,
                   end:this.from.time2,
                   type:2, //1拆解 2拆分
                    maid:this.from.select1_num    
                }).then(res => {

                    if(res.error_code == 0){
                      this.open1(res.result,'success')  //提示框
                      this.list_fun()
                      this.add_mtk = false
                    }else {
                    this.open1(res.message,'warning')
                }

        })
      },
      goBack() {
        this.$router.go(-1)
      },
    //   handleSizeChange(val) {
    //     console.log(`每页 ${val} 条`);
    //   },
    //   handleCurrentChange(val) {
    //     this.page = val
    //     this.list_fun()
    //     console.log(`当前页: ${val}`);
    //   }
  }
}
</script>


<style scoped>

</style>
